<!--自由课程调查页-->
<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="format-detection" content="telephone=no" />
		<meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
		<script src="../../script/mui.min.js"></script>
		<script src="../../script/jquery.min.js"></script>
		<link rel="stylesheet" href="../../css/mui.min.css" />
		<link rel="stylesheet" href="../../css/swiper-3.4.2.min.css">
		<link rel="stylesheet" type="text/css" href="../../css/weui.min.css">
		<link rel="stylesheet" href="../../css/base.css"/>
		<link rel="stylesheet" href="../../css/exam.css">
		<link rel="stylesheet" type="text/css" href="../../css/people_diaocha.css"/>
		<link rel="stylesheet" type="text/css" href="../../css/singlePeo_diaocha.css"/>
		<title>老师端调查列表详情页</title>
		<script type="text/javascript" charset="utf-8">
			mui.init();
		</script>
		<style>
			html {
				font-size: 10px;
			}
			.question_main .question_answer {
				padding: 0.2 rem 0rem 0rem 3rem;
				background: #fff;
				margin-bottom: 20px;
			}
			.question_title {
				font-size: 16px;
				color: #333333;
				padding: 0.5 rem 1.5 rem 1rem 1.5 rem;
			}
			.diaocha_question:nth-child(1) {
				padding-top: 10px;
			}
			.weui_mask {
				position: fixed;
				z-index: 998;
				top: 0;
				right: 0;
				bottom: 0;
				left: 0;
			}
			.weui_dialog {
				z-index: 999;
			}
			.swiper-wrapper {
				min-height: 40rem
			}
		</style>
	</head>
	<body >
		<div class="stu-test" id="scroll">
			<div class="base_style_color" id='BarAppearance' style="height: 22px;width: 100%; position:fixed; left: 0px;top:0px;z-index: 998" ></div>
			<div class="base_navigation_bar base_style_color base_navigation_item_bar" style="position: fixed;left: 0px;top: 20px;">
				<a class="base_left_item" href="#" onclick="backToast()"> <img class="base_back_icon" src="../../image/icon_jiantou.png" alt=""> </a>
				<span id="title"></span>
			</div>
			<div class="ReviewWeekly_div  " style="margin-top: 64px"></div>
			<div class="space10"></div>
			<div class="k-con test-m-bottom70 test-analysis" id="question_div">
				<div class="question_main">
					<div class="swiper-container">
						<div class="swiper-wrapper" ></div>
					</div>
				</div>
			</div>
			<div class="k-con1 k-text-center k-fixed-bottom test-bottom1" id="sub_div">
				<div class="k-con-part" id='score_bt' style="height:27px;display: none;">
					<div class="test_card_div" style="top: -10px">
						<a class="base_right_item "style="color: #18B4ED" href="#popover-card">答题卡 </a>
					</div>
				</div>
			</div>
			<div id="popover-card" class="mui-popover test-num-card" style="width: 95% ">
				<div class="mui-scroll-wrapper">
					<div class="mui-scroll" id="scroll-card"></div>
				</div>
			</div>
			<div id="backAlert" class="weui_dialog_confirm" style="display: none">
				<div class="weui_mask"></div>
				<div class="weui_dialog">
					<div class="weui_dialog_hd">
						<strong class="weui_dialog_title" id="checkNum"></strong>
					</div>
					<div class="weui_dialog_bd"></div>
					<div class="weui_dialog_ft">
						<a onclick="cleanCancel()" href="#" class="weui_btn_dialog default"  style="color:#18b4ed">取消</a>
						<a onclick="cleanConfirm()" href="#" class="weui_btn_dialog primary"  style="color:#18b4ed">确定</a>
					</div>
				</div>
			</div>
			<div class="weui_dialog_alert" id="closeAlert" style="display: none">
				<div class="weui_mask"></div>
				<div class="weui_dialog">
					<div class="weui_dialog_hd">
						<strong class="weui_dialog_title" id="checkNum2"></strong>
					</div>
					<div class="weui_dialog_ft">
						<a onclick="Cancel()" href="#" class="weui_btn_dialog primary"  style="color:#18b4ed">确定</a>
					</div>
				</div>
			</div>
		</div>
	</body>
	<script type="text/javascript" src="../../script/api.js"></script>
	<script src="../../script/jquery.min.js" type="text/javascript"></script>
	<script src="../../script/timecontrol.min.js"></script>
	<script type="text/javascript" src="../../script/MD5.js"></script>
	<script src="../../script/swiper-3.4.2.jquery.min.js" type="text/javascript"></script>
	<script type="text/javascript" src="../../script/requestTool.js"></script>
	<script type="text/javascript" src="../../script/echarts.min.js"></script>
	<script src="../../script/common.js"></script>
	<script>
		//题目名称数组
		var daan = new Object();
		var answerArr = new Array();
		var question_typeArr = new Array();
		var itemNameArr = new Array();
		var qidArr = new Array();
		var pid = "";
		// 计划id
		var cid = "";
		var clickNum = "";
		//课程id
		var chapterid = "";
		//章节id
		var timeNum = "";
		var questionLen = "";
		apiready = function() {
			var pageParam = api.pageParam;
			var h = api.winHeight * 0.3;
			$('#popover-card').css('height', h);
			$('#title').text(api.pageParam.name);
			//开启加载框
			showProgress();
			loadScoreData();
			receNotifi();
			//			loadExamData()
			// 滚动监听
			sendBuriedNotifi('0', '老师端调查结果页', '200')
		}
		function sendBuriedNotifi(busionessid, pagetype, pagetypeid) {
			var userinfo = {
				uid : $api.getStorage('cfnetppuid'),
				jid : $api.getStorage('cfnetppjxid'),
				uname : $api.getStorage('cfnetppusername'),
			}
			var data = {
				busionessid : busionessid,
				pagetype : pagetype,
				pagetypeid : pagetypeid,
				sourceurl : api.pageParam.sourceurl,
				sourcetitle : api.pageParam.sourcetitle,
				accesspageurl : window.location.pathname,
				accesspagetitle : document.title,
				userinfo : userinfo
			}
			SendBehaviorTrajectoriesNotifi_Study(data);
		}

		function receNotifi() {
			api.addEventListener({
				name : 'keyback'
			}, function(ret, err) {
				//coding...
				backToast();
			});
			api.addEventListener({
				name : 'pushMessage_classroomMessage'
			}, function(ret, err) {
				var notifiJid = ret.value.jid;
				var iid = ret.value.id;
				if (notifiJid == $api.getStorage('cfnetppjxid')) {//同一个集团
					if (iid == api.pageParam.id) {//同一个调查
						if (ret.value.status == 4) {//学生提交数据
							var DC_TYPE = ret.value.type;
							if (DC_TYPE == 10010) {
								$('.swiper-wrapper').html('');
								$("#scroll-card").html('');
								loadScoreData();
							}
						}
					}
				}
			});
		}

		function PopupHint2(str) {
			$("#checkNum2").text(str);
			$('#closeAlert').show();
		}

		function Cancel() {
			$('#closeAlert').hide();
			backClick();
		}

		//调查结果页
		function loadScoreData() {
			var param = {
				uid : $api.getStorage('cfnetppuid'),
				iid : api.pageParam.id,
			};
			cfnetppPOST(url_getSurveryResult, param, true, function(data, status) {
				hideProgress();
				if (status == 'success') {
					if (data.code == 200) {
						$('#score_bt').show();
						var list = data.data;
						if (list != null) {
							SetScoreUI(list);
						} else {
							api.toast({
								msg : '请在' + ludongJudge() + '活动结束后查看答案，目前暂时不支持查看调查结果',
								duration : 2000,
								location : 'bottom'
							});
						}
					} else if (data.code == 106) {
						api.toast({
							msg : '' + ludongJudge() + '未找见',
							duration : 2000,
							location : 'bottom'
						});
					} else {
						api.toast({
							msg : '没有更多数据了',
							duration : 2000,
							location : 'bottom'
						});
					}
				} else {
					api.toast({
						msg : '没有更多数据了',
						duration : 2000,
						location : 'bottom'
					});
				}
			});
		}

		//是否是鲁东智慧课堂
		function ludongJudge() {
			//读取消息推送
			var jid = $api.getStorage('cfnetppjxid');
			if (jid != 425) {//非鲁东智能课堂
				return '调查'
			} else {
				return '投票'
			}
		}

		function SetScoreUI(list) {
			var data = list;
			questionLen = data.length;
			//	生成答题卡题号
			popoverCardNum(questionLen);
			var orderNum = "";
			for (var i = 0; i < questionLen; i++) {
				orderNum = (i + 1) + '/' + questionLen;
				$(".swiper-wrapper").append('<div class="swiper-slide">' + '<div class="diaocha_question"  id="item' + (i + 1) + '"  itemtype="' + data[i].subsecttitle + '">' + '</div>' + '</div>');
				$("#item" + (i + 1)).append('<p class="question_title">' + '<span>Q' + orderNum + '</span>' + htmlspecialchars_decode(data[i].title) + '<span class="question_type">' + '(' + data[i].subsecttitle + ')' + '</span>' + '</p>' + '<ul class="question_answer">' + '</ul>');
				if (data[i].subsecttitle == '单选题') {
					for (var k = 0; k < data[i].options.answer.length; k++) {
						var optionStr = "option" + ((k + 1) % 7);
						var BgStr = "Bg" + ((k + 1) % 7);
						var optionStr2 = htmlspecialchars_decode(data[i].options.answer[k].option_title.desc)
						var PercentageStr = PercentageIsNull(((data[i].options.answer[k].option_num) / (data[i].options.answer[k].option_sum)) * 100) + "%";
						$("#item" + (i + 1) + " .question_answer").append('<li>' + '<p style="font-size:14px">' + '<span>' + fromCharCode(k + 1) + '</span>' + '<span class="left_5">' + optionStr2 + '</span>' + '</p>' + '<div class="progressBar ' + optionStr + '">' + '<div class="Bar_left ' + optionStr + '">' + '<div class="bar_in ' + BgStr + '"></div>' + '</div>' + '<div class="Bar_center">' + PercentageStr + '</div>' + '<div class="Bar_right"><img src="../../image/icon_Pmini.png" alt="">' + '<span>' + data[i].options.answer[k].option_num + '</span>' + '</div>' + '</div>' + '</li>');
					}
				} else if (data[i].subsecttitle == '多选题') {
					for (var k = 0; k < data[i].options.answer.length; k++) {
						var optionStr = "option" + ((k + 1) % 7);
						var BgStr = "Bg" + ((k + 1) % 7);
						var optionStr2 = htmlspecialchars_decode(data[i].options.answer[k].option_title.desc)
						var PercentageStr = PercentageIsNull(((data[i].options.answer[k].option_num) / (data[i].options.answer[k].option_sum)) * 100) + "%";
						$("#item" + (i + 1) + " .question_answer").append('<li>' + '<p style="font-size:14px">' + '<span>' + fromCharCode(k + 1) + '</span>' + '<span class="left_5">' + optionStr2 + '</span>' + '</p>' + '<div class="progressBar ' + optionStr + '">' + '<div class="Bar_left ' + optionStr + '">' + '<div class="bar_in ' + BgStr + '"></div>' + '</div>' + '<div class="Bar_center">' + PercentageStr + '</div>' + '<div class="Bar_right"><img src="../../image/icon_Pmini.png" alt="">' + '<span>' + data[i].options.answer[k].option_num + '</span>' + '</div>' + '</div>' + '</li>');
					}
				} else if (data[i].subsecttitle == '论述题') {
					// 论述
					$("#item" + (i + 1) + " .test-answer-list").append('<div  class="test-answer-statistics" id="item">无数据统计</div>')
				}
				GetWidth();
			}
			var mySwiper = new Swiper('.swiper-container', {
				autoHeight : true,
				//用户操作swiper之后，是否禁止autoplay
				autoplayDisableOnInteraction : true,
				direction : 'horizontal',
				loop : false,
			})
			//  试题总数
			allQuestionNum(questionLen);
			// 点击答题卡切换
			$("#popover-card span").on("click", function() {
				//				gallery.slider().gotoItem($(this).index())
				var index = $(this).index();
				mySwiper.slideTo(index, 1000, false);
				mui('#popover-card').popover('hide')
			});
		}

		//  试题总数
		function allQuestionNum(questionLen) {
			$("#questionLength").text("/" + questionLen)
		}

		//	生成答题卡题号
		function popoverCardNum(questionLen) {
			for (var i = 0; i < questionLen; i++)
				$("#scroll-card").append('<span class="qusetion-num-normal">' + (i + 1) + '</span>')
		}

		//退出考试提示
		function backToast() {
			sendBuriedNotifi('1', '老师端调查结果页', '200')
			api.closeToWin({
				name : 'Teacher_ResearchWindow'
			});
		}

		function cleanCancel() {
			$('#backAlert').hide();
		}

		//确定
		function cleanConfirm() {
			$('#backAlert').hide();
			if (clickNum == 1) {
			} else if (clickNum == 2 || clickNum == 4) {
				backClick();
			}
		}
	</script>
</html>